package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 采购物品表
 */
@JsonApiResource(type = "purchasegood")
@Table(name = "tnb_purchase_goods")
@Entity
// @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class PurchaseGood extends BaseEntity {

	private String remark;// 备注 

	private String name;// 物品名称

	private Double unitPrice;// 单价

	private Double totalPrice;// 总价

	private Double purchaseNum;// shuliang

	private Integer createDateTime;// 创建时间

	private User createUser;

	private User lastUpdateUser;

	private Integer lastUpdateDateTime;// 更新时间

	private Dicttype purchaseType;// 类型

	private Cargo goods;
	
	private Integer purchaseTime;// 时间

	@Column(name = "purchase_time")
	public Integer getPurchaseTime() {
		return purchaseTime;
	}

	public void setPurchaseTime(Integer purchaseTime) {
		this.purchaseTime = purchaseTime;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "goods_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public Cargo getGoods() {
		return goods;
	}

	public void setGoods(Cargo goods) {
		this.goods = goods;
	}

	@Column(name = "purchase_num")
	public Double getPurchaseNum() {
		return purchaseNum;
	}

	public void setPurchaseNum(Double purchaseNum) {
		this.purchaseNum = purchaseNum;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createUser_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@Column(name = "unit_price")
	public Double getUnitPrice() {
		return unitPrice;
	}

	public void setUnitPrice(Double unitPrice) {
		this.unitPrice = unitPrice;
	}

	@Column(name = "total_price")
	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		this.totalPrice = totalPrice;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "type_id", nullable = true, foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPurchaseType() {
		return purchaseType;
	}

	public void setPurchaseType(Dicttype purchaseType) {
		this.purchaseType = purchaseType;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "lastUpdateUser_ID", nullable = true, foreignKey = @ForeignKey(name = "null"))
	// @JsonBackReference
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}
